/*
 * Copyright (c) 2021.版权所有高金磊
 */

package 领扣算法.AA中等题.比较版本号;

import jnr.ffi.annotations.In;

import java.util.Date;
import java.util.LinkedList;

public class Main {
    public static void main(String arg[]) {//main--来自高金磊

//        System.out.println(("1.01".split("/.")).length);
        new Main().compareVersion("0.01.4157456415", "1.01");
    }

    public int compareVersion(String version1, String version2) {
        LinkedList<Integer> data = new LinkedList<>();
        for (String s : version1.split("\\.")) {
            data.addLast(Integer.valueOf(s));
        }
        int middle;

        for (String s : version2.split("\\.")) {
            if (data.isEmpty()) {
                middle = 0;
            } else
                middle = data.pollFirst();
            if (Integer.valueOf(s) < middle)
                return 1;
            if (Integer.valueOf(s) > middle)
                return -1;
        }

        for (Integer datum : data) {
            if (datum > 0)
                return 1;
        }
        return 0;
    }
}
